import { getCustomers, deleteCustomers } from '@/api/customer'


const state = {
  customers: []//所有客户
}

const mutations = {
  GET_ALL_CUSTOMERS: (state, new_sellers_data) => {
    state.customers = new_sellers_data
  },
  NULL: () => { }
}

const actions = {
  //分页获取全部销售
  getAllCustomers ({ commit }, params) {
    return new Promise((resolve, reject) => {
      getCustomers(params).then(response => {
        console.log(response);
        if (response) {
          commit('GET_ALL_CUSTOMERS', response.data.records)
        }
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //批量删除销售
  deletes ({ commit }, ids) {
    return new Promise((resolve, reject) => {
      deleteCustomers(ids).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}